{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: deeppavlov in /home/alexeysorokin/data/DeepPavlov\n",
      "Requirement already satisfied: Cython==0.28.5 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: overrides==1.9 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: numpy==1.14.5 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: pandas==0.23.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: nltk==3.2.5 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: tqdm==4.23.4 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: scipy==1.1.0 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: h5py==2.8.0 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: keras==2.2.0 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: scikit-learn==0.19.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: fuzzywuzzy==0.16.0 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: pymorphy2==0.8 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: pymorphy2-dicts-ru in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: requests==2.19.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: pytelegrambotapi==3.5.2 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: flask==1.0.2 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: flasgger==0.9.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: flask_cors==3.0.6 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: rusenttokenize==0.0.4 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from deeppavlov)\n",
      "Requirement already satisfied: pytz>=2011k in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from pandas==0.23.1->deeppavlov)\n",
      "Requirement already satisfied: python-dateutil>=2.5.0 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from pandas==0.23.1->deeppavlov)\n",
      "Requirement already satisfied: six in /usr/lib/python3/dist-packages (from nltk==3.2.5->deeppavlov)\n",
      "Requirement already satisfied: keras-applications==1.0.2 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from keras==2.2.0->deeppavlov)\n",
      "Requirement already satisfied: keras-preprocessing==1.0.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from keras==2.2.0->deeppavlov)\n",
      "Requirement already satisfied: pyyaml in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from keras==2.2.0->deeppavlov)\n",
      "Requirement already satisfied: docopt>=0.6 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from pymorphy2==0.8->deeppavlov)\n",
      "Requirement already satisfied: pymorphy2-dicts<3.0,>=2.4 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from pymorphy2==0.8->deeppavlov)\n",
      "Requirement already satisfied: dawg-python>=0.7 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from pymorphy2==0.8->deeppavlov)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from requests==2.19.1->deeppavlov)\n",
      "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3/dist-packages (from requests==2.19.1->deeppavlov)\n",
      "Requirement already satisfied: idna<2.8,>=2.5 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from requests==2.19.1->deeppavlov)\n",
      "Requirement already satisfied: urllib3<1.24,>=1.21.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from requests==2.19.1->deeppavlov)\n",
      "Requirement already satisfied: Jinja2>=2.10 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flask==1.0.2->deeppavlov)\n",
      "Requirement already satisfied: Werkzeug>=0.14 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flask==1.0.2->deeppavlov)\n",
      "Requirement already satisfied: click>=5.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flask==1.0.2->deeppavlov)\n",
      "Requirement already satisfied: itsdangerous>=0.24 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flask==1.0.2->deeppavlov)\n",
      "Requirement already satisfied: mistune in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flasgger==0.9.1->deeppavlov)\n",
      "Requirement already satisfied: jsonschema>=2.5.1 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from flasgger==0.9.1->deeppavlov)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages (from Jinja2>=2.10->flask==1.0.2->deeppavlov)\n",
      "\u001b[33mYou are using pip version 9.0.3, however version 18.1 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install deeppavlov"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from deeppavlov import build_model, configs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We download and build model from configuration file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2018-11-23 16:30:00.367 DEBUG in 'urllib3.connectionpool'['connectionpool'] at line 205: Starting new HTTP connection (1): files.deeppavlov.ai:80\n",
      "2018-11-23 16:30:00.419 DEBUG in 'urllib3.connectionpool'['connectionpool'] at line 393: http://files.deeppavlov.ai:80 \"GET /deeppavlov_data/morpho_tagger/UD2.0/ru_syntagrus.tar.gz.md5 HTTP/1.1\" 200 237\n",
      "2018-11-23 16:30:00.462 INFO in 'deeppavlov.download'['download'] at line 115: Skipped http://files.deeppavlov.ai/deeppavlov_data/morpho_tagger/UD2.0/ru_syntagrus.tar.gz download because of matching hashes\n",
      "2018-11-23 16:30:00.464 DEBUG in 'urllib3.connectionpool'['connectionpool'] at line 205: Starting new HTTP connection (1): files.deeppavlov.ai:80\n",
      "2018-11-23 16:30:00.530 DEBUG in 'urllib3.connectionpool'['connectionpool'] at line 393: http://files.deeppavlov.ai:80 \"GET /datasets/UD2.0_source/ru_syntagrus.tar.gz.md5 HTTP/1.1\" 200 255\n",
      "2018-11-23 16:30:00.671 INFO in 'deeppavlov.download'['download'] at line 115: Skipped http://files.deeppavlov.ai/datasets/UD2.0_source/ru_syntagrus.tar.gz download because of matching hashes\n",
      "[nltk_data] Downloading package punkt to\n",
      "[nltk_data]     /home/alexeysorokin/nltk_data...\n",
      "[nltk_data]   Package punkt is already up-to-date!\n",
      "[nltk_data] Downloading package stopwords to\n",
      "[nltk_data]     /home/alexeysorokin/nltk_data...\n",
      "[nltk_data]   Package stopwords is already up-to-date!\n",
      "[nltk_data] Downloading package perluniprops to\n",
      "[nltk_data]     /home/alexeysorokin/nltk_data...\n",
      "[nltk_data]   Package perluniprops is already up-to-date!\n",
      "[nltk_data] Downloading package nonbreaking_prefixes to\n",
      "[nltk_data]     /home/alexeysorokin/nltk_data...\n",
      "[nltk_data]   Package nonbreaking_prefixes is already up-to-date!\n",
      "2018-11-23 16:30:01.266 INFO in 'deeppavlov.core.data.vocab'['vocab'] at line 175: [loading vocabulary from /home/alexeysorokin/.deeppavlov/models/morpho_tagger/UD2.0/ru_syntagrus/tag.dict]\n",
      "2018-11-23 16:30:01.268 INFO in 'deeppavlov.core.data.vocab'['vocab'] at line 175: [loading vocabulary from /home/alexeysorokin/.deeppavlov/models/morpho_tagger/UD2.0/ru_syntagrus/char.dict]\n",
      "2018-11-23 16:30:01.283 INFO in 'pymorphy2.opencorpora_dict.wrapper'['wrapper'] at line 16: Loading dictionaries from /home/alexeysorokin/data/DeepPavlov/venv/lib/python3.6/site-packages/pymorphy2_dicts/data\n",
      "2018-11-23 16:30:01.313 INFO in 'pymorphy2.opencorpora_dict.wrapper'['wrapper'] at line 20: format: 2.4, revision: 393442, updated: 2015-01-17T16:03:56.586168\n",
      "Using TensorFlow backend.\n",
      "2018-11-23 16:30:02.320 INFO in 'deeppavlov.models.morpho_tagger.network'['network'] at line 126: 99 symbols, 711 tags in CharacterTagger\n",
      "2018-11-23 16:30:02.904 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 106: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.905 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "2018-11-23 16:30:02.905 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 108: ==================================================================================================\n",
      "2018-11-23 16:30:02.906 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: input_1 (InputLayer)            (None, None, 32)     0                                            \n",
      "2018-11-23 16:30:02.906 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.907 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: lambda_1 (Lambda)               (None, None, 32, 99) 0           input_1[0][0]                    \n",
      "2018-11-23 16:30:02.907 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.907 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: dense_1 (Dense)                 (None, None, 32, 32) 3168        lambda_1[0][0]                   \n",
      "2018-11-23 16:30:02.908 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.908 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_1 (Conv2D)               (None, None, 32, 50) 1650        dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.909 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.909 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_2 (Conv2D)               (None, None, 32, 100 6500        dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.909 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.910 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_3 (Conv2D)               (None, None, 32, 150 14550       dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.911 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.911 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_4 (Conv2D)               (None, None, 32, 200 25800       dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.912 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.912 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_5 (Conv2D)               (None, None, 32, 200 32200       dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.913 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.913 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_6 (Conv2D)               (None, None, 32, 200 38600       dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.914 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.914 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: conv2d_7 (Conv2D)               (None, None, 32, 200 45000       dense_1[0][0]                    \n",
      "2018-11-23 16:30:02.914 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.915 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: concatenate_1 (Concatenate)     (None, None, 32, 110 0           conv2d_1[0][0]                   \n",
      "2018-11-23 16:30:02.915 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_2[0][0]                   \n",
      "2018-11-23 16:30:02.916 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_3[0][0]                   \n",
      "2018-11-23 16:30:02.916 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_4[0][0]                   \n",
      "2018-11-23 16:30:02.917 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_5[0][0]                   \n",
      "2018-11-23 16:30:02.917 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_6[0][0]                   \n",
      "2018-11-23 16:30:02.918 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  conv2d_7[0][0]                   \n",
      "2018-11-23 16:30:02.918 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.919 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: lambda_2 (Lambda)               (None, None, 1100)   0           concatenate_1[0][0]              \n",
      "2018-11-23 16:30:02.919 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.920 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: input_2 (InputLayer)            (None, None, 724)    0                                            \n",
      "2018-11-23 16:30:02.920 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.921 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: highway_1 (Highway)             (None, None, 1100)   2422200     lambda_2[0][0]                   \n",
      "2018-11-23 16:30:02.921 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.922 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: dense_2 (Dense)                 (None, None, 128)    92800       input_2[0][0]                    \n",
      "2018-11-23 16:30:02.923 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.923 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: concatenate_2 (Concatenate)     (None, None, 1228)   0           highway_1[0][0]                  \n",
      "2018-11-23 16:30:02.924 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104:                                                                  dense_2[0][0]                    \n",
      "2018-11-23 16:30:02.924 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.924 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: dropout_1 (Dropout)             (None, None, 1228)   0           concatenate_2[0][0]              \n",
      "2018-11-23 16:30:02.925 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.926 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: bidirectional_1 (Bidirectional) (None, None, 256)    1389568     dropout_1[0][0]                  \n",
      "2018-11-23 16:30:02.926 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 170: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.927 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 104: p (TimeDistributed)             (None, None, 711)    182727      bidirectional_1[0][0]            \n",
      "2018-11-23 16:30:02.927 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 168: ==================================================================================================\n",
      "2018-11-23 16:30:02.928 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 181: Total params: 4,254,763\n",
      "2018-11-23 16:30:02.929 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 182: Trainable params: 4,254,763\n",
      "2018-11-23 16:30:02.929 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 183: Non-trainable params: 0\n",
      "2018-11-23 16:30:02.929 INFO in 'deeppavlov.models.morpho_tagger.network'['layer_utils'] at line 184: __________________________________________________________________________________________________\n",
      "2018-11-23 16:30:02.932 INFO in 'deeppavlov.core.models.keras_model'['keras_model'] at line 144: [loading model from /home/alexeysorokin/.deeppavlov/models/morpho_tagger/UD2.0/ru_syntagrus/model_pymorphy.hdf5]\n"
     ]
    }
   ],
   "source": [
    "model = build_model(configs.morpho_tagger.UD2_0.morpho_ru_syntagrus_pymorphy, download=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let us parse several example sentences."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\tЯ\tPRON\tCase=Nom|Number=Sing|Person=1\n",
      "2\tшёл\tVERB\tAspect=Imp|Gender=Masc|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act\n",
      "3\tдомой\tADV\tDegree=Pos\n",
      "4\tпо\tADP\t_\n",
      "5\tнезнакомой\tADJ\tCase=Dat|Degree=Pos|Gender=Fem|Number=Sing\n",
      "6\tулице\tNOUN\tAnimacy=Inan|Case=Dat|Gender=Fem|Number=Sing\n",
      "7\t.\tPUNCT\t_\n",
      "\n",
      "1\tДевушка\tNOUN\tAnimacy=Anim|Case=Nom|Gender=Fem|Number=Sing\n",
      "2\tпела\tVERB\tAspect=Imp|Gender=Fem|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act\n",
      "3\tв\tADP\t_\n",
      "4\tцерковном\tADJ\tCase=Loc|Degree=Pos|Gender=Masc|Number=Sing\n",
      "5\tхоре\tNOUN\tAnimacy=Inan|Case=Loc|Gender=Masc|Number=Sing\n",
      "6\tо\tADP\t_\n",
      "7\tвсех\tPRON\tAnimacy=Anim|Case=Loc|Number=Plur\n",
      "8\tуставших\tVERB\tAspect=Perf|Case=Loc|Number=Plur|Tense=Past|VerbForm=Part|Voice=Act\n",
      "9\tв\tADP\t_\n",
      "10\tчужом\tADJ\tCase=Loc|Degree=Pos|Gender=Masc|Number=Sing\n",
      "11\tкраю\tNOUN\tAnimacy=Inan|Case=Loc|Gender=Masc|Number=Sing\n",
      "12\t.\tPUNCT\t_\n",
      "\n"
     ]
    }
   ],
   "source": [
    "sentences = [\"Я шёл домой по незнакомой улице.\", \"Девушка пела в церковном хоре о всех уставших в чужом краю.\"]\n",
    "\n",
    "for parse in model(sentences):\n",
    "    print(parse)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Model also works with already tokenized sentences."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\tЯ\tPRON\tCase=Nom|Number=Sing|Person=1\n",
      "2\tшёл\tVERB\tAspect=Imp|Gender=Masc|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act\n",
      "3\tдомой\tADV\tDegree=Pos\n",
      "4\tпо\tADP\t_\n",
      "5\tнезнакомой\tADJ\tCase=Dat|Degree=Pos|Gender=Fem|Number=Sing\n",
      "6\tулице\tNOUN\tAnimacy=Inan|Case=Dat|Gender=Fem|Number=Sing\n",
      "7\t.\tPUNCT\t_\n",
      "\n"
     ]
    }
   ],
   "source": [
    "sentences = [[\"Я\", \"шёл\", \"домой\", \"по\", \"незнакомой\", \"улице\", \".\"]]\n",
    "\n",
    "for parse in model(sentences):\n",
    "    print(parse)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We need to change output prettifier parameters to get UD output. The same result is obtained by editing the configuration file (see http://docs.deeppavlov.ai/en/master/components/morphotagger.html)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\tЯ\t_\tPRON\t_\tCase=Nom|Number=Sing|Person=1\t_\t_\t_\t_\n",
      "2\tшёл\t_\tVERB\t_\tAspect=Imp|Gender=Masc|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act\t_\t_\t_\t_\n",
      "3\tдомой\t_\tADV\t_\tDegree=Pos\t_\t_\t_\t_\n",
      "4\tпо\t_\tADP\t_\t_\t_\t_\t_\t_\n",
      "5\tнезнакомой\t_\tADJ\t_\tCase=Dat|Degree=Pos|Gender=Fem|Number=Sing\t_\t_\t_\t_\n",
      "6\tулице\t_\tNOUN\t_\tAnimacy=Inan|Case=Dat|Gender=Fem|Number=Sing\t_\t_\t_\t_\n",
      "7\t.\t_\tPUNCT\t_\t_\t_\t_\t_\t_\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prettifier = model.pipe[-1][-1]\n",
    "prettifier.set_format_mode(\"ud\")\n",
    "\n",
    "for parse in model(sentences):\n",
    "    print(parse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "name": "python3"
  },
  "accelerator": "GPU",
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
